package com.lambert.young.im.handler;

import com.lambert.young.im.IMServer;
import io.netty.channel.Channel;

import java.util.Timer;
import java.util.TimerTask;

/**
 * <p>TODO </p>
 *
 * @author liubaolin
 * @since 2024/11/1 10:54 AM
 */
public class UserHandler {
    public static void execute(){
        TimerTask timerTask = new TimerTask() {
            @Override
            public void run() {
                IMServer.USERS.values().removeIf(channel -> {
                    if (channel instanceof Channel chat) {
                        return !chat.isOpen() || !chat.isActive() || !chat.isRegistered();
                    }
                    return false;
                });
            }
        };
        new Timer().schedule(timerTask,0,100);
    }
}
